class DevAccess {
    Role role
    String userName
    String password

    //static belongsTo = [Employee, Area, Container]

    static constraints = {

    }
    public Boolean hasDevAuth(){
        return role.level == 0
    }
    public Boolean hasAdminAuth(){
        return role.level == 1
    }
    public Boolean hasManagerAuth(){
        return role.level == 2
    }
    
    public List getList(String controller){
        switch(controller){
            case "project" :
                if(hasDevAuth()){
                    //return Project.list()
                    if(DBConnection.isConnectionStarted()){

                        return DBConnection.getProjectList()
                    }
                    else{
                        return Project.list()
                    }
                }
            break
        }
    }
    public Boolean checkAccess(String controller, String action, Long id){
       // if(controller.equalsIgnoreCase("area")){
            switch(action){
                case "show" :
                    if(hasDevAuth()){
                        return true
                    }
                    return false
                    break
                case "create" :
                    if(hasDevAuth()){
                        return true
                    }
                    else return false
                    break
                case "edit" :
                    if(hasDevAuth()){
                        return true
                    }
                    return false
                    break
                case "delete" :
                    if(hasDevAuth()){
                        return true
                    }
                    return false
                    break
                case "save" :
                    if(hasDevAuth()){
                        return true
                    }
                    return false
                    break
                default : return false
                }
            }
           // else{
           //     return false
           // }
        //}
    //String toString(){"${this.emp} : ${this.role}"}
    String toString(){"${this.role}"}
}